#!/bin/sh

# chkconfig:   345 99 99
# description: Swignition Daemon

. /etc/rc.d/init.d/functions

SWIGDIR=/opt/swignition/

case "$1" in
start)
echo -n "Starting service: "
perl -I$SWIGDIR $SWIGDIR/swignitiond.pl
echo
;;

clean)
echo -n "Cleaning swignitiond cache: "
rm -fr /tmp/swignition*cache
echo
;;

stop)
echo -n "Shutting down service: "
kill `cat /tmp/swignition.pid`
rm -f /tmp/swignition.pid
echo
;;

status)
cat /tmp/swignition.pid
;;

restart)
echo -n "Shutting down service: "
kill `cat /tmp/swignition.pid`
echo
echo -n "Starting service: "
perl -I$SWIGDIR $SWIGDIR/swignitiond.pl
echo
;;

clean)
echo -n "Shutting down service: "
kill `cat /tmp/swignition.pid`
echo
echo -n "Cleaning swignitiond cache: "
rm -fr /tmp/swignition*cache
echo  
echo -n "Starting service: "
perl -I$SWIGDIR $SWIGDIR/swignitiond.pl
echo
;;

*)
echo "*** Usage: service_name 'start|stop|status|restart|clean'"
exit 1
esac
exit 0

